package com.supersit.greensproject.adapter;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.supersit.greensproject.utils.T;

public class FragmentAdapter extends FragmentPagerAdapter {
    private String[] tabTitle;
    private List<Fragment> fragmentList;
    public static final String ARGUMENTS_NAME = "arg";

    public FragmentAdapter(FragmentManager fm, List<Fragment> fragmentList, String[] tabTitle) {
        super(fm);
        this.fragmentList = fragmentList;
        this.tabTitle = tabTitle;
    }

    @Override
    public Fragment getItem(int arg0) {
        Fragment ft = null;
        switch (arg0) {
            case 0:
                ft = fragmentList.get(0);
                break;

            default:
                ft = fragmentList.get(1);

                Bundle args = new Bundle();
                args.putString(ARGUMENTS_NAME, tabTitle[arg0]);
                ft.setArguments(args);

                break;
        }
        return ft;
    }

    @Override
    public int getCount() {

        return tabTitle.length;
    }


}
